#include "usersmanagerwdg.h"
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QGroupBox>
#include <QPushButton>
#include <QTableWidget>
#include <QLineEdit>

UsersManagerWdg::UsersManagerWdg():
    m_pAddButton(new QPushButton(tr("Add"))),
    m_pDeleteButton(new QPushButton(tr("Delete"))),
    m_pModifyButton(new QPushButton(tr("Modify"))),
    m_pNameLineEdit(new QLineEdit),
    m_pPasswordComfirmLineEdit(new QLineEdit),
    m_pPasswordLineEdit(new QLineEdit),
    m_pUsersTableWdg(new QTableWidget)
{
    setObjectName("UsersManagerWdg");
    resize(600,400);

    m_pAddButton->setObjectName("m_pAddButton");
    m_pDeleteButton->setObjectName("m_pDeleteButton");
    m_pModifyButton->setObjectName("m_pModifyButton");

    //table
    m_pUsersTableWdg->setColumnCount(2);
    QStringList headerStrList;
    headerStrList.append(tr("ID"));
    headerStrList.append(tr("Type"));
    m_pUsersTableWdg->setHorizontalHeaderLabels(headerStrList);

    QHBoxLayout *tableHLayout=new QHBoxLayout;
    tableHLayout->addWidget(m_pUsersTableWdg);

    QGroupBox *tableGroupBox=new QGroupBox;
    tableGroupBox->setObjectName("tableGroupBox");
    tableGroupBox->setTitle(tr("User List"));
    tableGroupBox->setLayout(tableHLayout);

    //setting
    QLabel *userLabel=new QLabel(tr("UserName:"));
    userLabel->setObjectName("userLabel");
    QLabel *passwordLabel=new QLabel(tr("Password:"));
    passwordLabel->setObjectName("passwordLabel");
    QLabel *confirmLabel=new QLabel(tr("Confirm Password:"));
    confirmLabel->setObjectName("confirmLabel");

    QFormLayout *formLayout=new QFormLayout;
    formLayout->addRow(userLabel,m_pNameLineEdit);
    formLayout->addRow(passwordLabel,m_pPasswordLineEdit);
    formLayout->addRow(confirmLabel,m_pPasswordComfirmLineEdit);

    QHBoxLayout *buttonHLayout=new QHBoxLayout;
    buttonHLayout->addStretch(1);
    buttonHLayout->addWidget(m_pModifyButton);
    buttonHLayout->addWidget(m_pAddButton);
    buttonHLayout->addWidget(m_pDeleteButton);

    QVBoxLayout *settingVLayout=new QVBoxLayout;
    settingVLayout->addLayout(formLayout);
    settingVLayout->addLayout(buttonHLayout);
    settingVLayout->addStretch(1);

    QGroupBox *settingGroupBox=new QGroupBox;
    settingGroupBox->setObjectName("settingGroupBox");
    settingGroupBox->setTitle(tr("User Info"));
    settingGroupBox->setLayout(settingVLayout);
    //layout
    QHBoxLayout *layout=new QHBoxLayout;
    //    layout->addLayout(tableHLayout);
    //    layout->addLayout(settingVLayout);
    layout->addWidget(tableGroupBox);
    layout->addWidget(settingGroupBox);

    setLayout(layout);
}

UsersManagerWdg::~UsersManagerWdg()
{

}
